#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include "common.h"
//#include "exec2.c"

int main()
{
	char policyName[10];	
	char appID[10];	
	char* desInt[10];
	char inter[10];
	char inter1[10];
	char inter2[10];		
	char inter3[10];
	char desLocation[10];
	char** returnedInterfaces;
	int desCost;
	int desBand;
	int count;
	char costArr[10];
	char bandArr[10];
	int i;
	int retCount=0;	
	printf("Enter the policyName - ");
	scanf("%s",policyName);
	printf("Enter the Application ID - ");
	scanf("%s",appID);
	printf("Enter the number of interfaces you wish to use - ");
	scanf("%d",&count);
	if(count==1)
	{
		printf("Enter the interface you wish to use - ");
		scanf("%s",inter1);
		desInt[0]=inter1;
	}	
	if(count==2)	
	{
		printf("Enter the interface you wish to use - ");
		scanf("%s",inter1);
		desInt[0]=inter1;
		printf("Enter the interface you wish to use - ");
		scanf("%s",inter2);
		desInt[1]=inter2;
	}
	if(count==3)
	{
		printf("Enter the interface you wish to use - ");
		scanf("%s",inter1);
		desInt[0]=inter1;
		printf("Enter the interface you wish to use - ");
		scanf("%s",inter2);
		desInt[1]=inter2;
		printf("Enter the interface you wish to use - ");
		scanf("%s",inter3);
		desInt[2]=inter3;
	}	
	//printf("Enter the interface you wish to use - ");
	//scanf("%s",desInt);
	printf("Enter the maximum cost - ");
	scanf("%d",&desCost);
	printf("Enter the minimum bandwidth - ");
	scanf("%d",&desBand);
	printf("Enter the location - ");
	scanf("%s",desLocation);

	// Building the rules.

	//createPolicy(policyName, desInt, itoa(desCost, costArr, 10), desLocation, itoa(desBand, bandArr, 10));
	createPolicy(policyName, desInt, "400", desLocation, "200", count, appID);	
	returnedInterfaces = (char **) malloc (sizeof(char) * 100);
	// Checking the Interface status schema.
	//char* interface = policy(desInt, desCost, desBand);
	//returnedInterfaces=policy(10);
	
	//retCount = policy(atoi(appID), returnedInterfaces);	
	/*	
	printf("%d", retCount);
	for(i=0;i<retCount;i++)
	{
		printf("We have  %s", returnedInterfaces[i]);
	}
	*/	
	//printf("Connection made on - %s\n\n",interface);
		
	//char* prequery = "sudo ./send_tcp 192.168.75.39 3000 5000";
	
	// Concatenating the two strings.	
	//char* query = malloc(snprintf(NULL, 0, "%s %s", prequery, interface) + 1);
	//sprintf(query, "%s %s", prequery, interface);	
	//printf("query = %s\n\n",query);
	//int x = system(query);
	
}

